#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char const *argv[])
{
    printf("主线程(%d)\n",getpid());
    pid_t pid = fork();
    if (pid == -1)
    {
        printf("fork error\n");
        return -1;
    }
    else if (pid == 0)
    {
        printf("子线程(%d)执行，父线程%d\n",getpid(),getppid());
    }
    else
    {
        printf("父线程(%d),子线程%d\n",getpid(),getppid());
    }
    return 0;
}
